﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CustomControlz.XtraEditors.LookUps;
using DevExpress.XtraEditors.Repository;
using Model;
using Utilities;
namespace DataAccess
{
    public class ClsDataFn
    {

        public void SetDataSource(ClsGlobalEnums.EDataSourceType eDsType, ccGridLookUpEdit lucEdit, string displayMember, string valueMember)
        {
            var context = new AccManagerEntities();
            switch (eDsType)
            {
                case ClsGlobalEnums.EDataSourceType.AccGroups:
                    lucEdit.Properties.DataSource = context.AccountGroups.ToList();
                    break;
                case ClsGlobalEnums.EDataSourceType.ItemTypes:
                    var lst = context.ItemTypeMasters.ToList();
                    lst.Insert(0, new ItemTypeMaster { ItemTypeId = -1, ItemTypeName = "All", ItemTypeCode = "All" });
                    lucEdit.Properties.DataSource = lst;
                    break;
                case ClsGlobalEnums.EDataSourceType.Accounts:
                    lucEdit.Properties.DataSource = context.AccountMasters.ToList();
                    break;
                case ClsGlobalEnums.EDataSourceType.Units:
                    lucEdit.Properties.DataSource = context.UnitMasters.ToList();
                    break;
                case ClsGlobalEnums.EDataSourceType.Cities:
                    lucEdit.Properties.DataSource = context.CityMasters.ToList();
                    break;
                case ClsGlobalEnums.EDataSourceType.Items:
                    lucEdit.Properties.DataSource = context.ItemMasters.ToList();
                    break;
                case ClsGlobalEnums.EDataSourceType.Stores:
                    lucEdit.Properties.DataSource = context.StoreMasters.ToList();
                    break;
                default:
                    break;
            }
            lucEdit.Properties.DisplayMember = displayMember;
            lucEdit.Properties.ValueMember = valueMember;
        }

        public void SetDataSource(ClsGlobalEnums.EDataSourceType eDsType, RepositoryItemGridLookUpEdit repLucItems, string displayMember, string valueMember)
        {
            var context = new AccManagerEntities();
            switch (eDsType)
            {
                case ClsGlobalEnums.EDataSourceType.Items:
                    repLucItems.DataSource = context.ItemMasters.ToList();
                    break;
                default:
                    break;
            }
            repLucItems.DisplayMember = displayMember;
            repLucItems.ValueMember = valueMember;
        }


    }
}
